import time
from selenium import webdriver
from selenium.webdriver.common.by import By


class MailLogin:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.driver.get('https://mail.163.com/')
        time.sleep(3)

    # 登录
    def login(self):
        # 先切换进去iframe标签
        frame1 = self.driver.find_element(By.XPATH, '//*[contains(@id,"x-URS-iframe")]')
        self.driver.switch_to.frame(frame1)
        self.driver.find_element(By.XPATH, '//input[@data-placeholder="邮箱帐号或手机号码"]').send_keys('yangyu18827553053')
        time.sleep(3)
        self.driver.find_element(By.XPATH, '//input[@data-placeholder="输入密码"]').send_keys('Yy101206')
        time.sleep(3)
        self.driver.find_element(By.XPATH, '//a[@id="dologin"]').click()
        time.sleep(3)

    def quit(self):
        time.sleep(5)
        self.driver.quit()


if __name__ == '__main__':
    case = MailLogin()
    case.login()
    case.quit()